package com.appspringboot.common;

public class RestResponse<T> {
	private int statusCode; //code全平台唯一
	private String msg="";
	private String msgEN="";
	private T data;

	public RestResponse(){
		super();
	}

	public RestResponse(T data){
		if(data instanceof BIException){
			this.msg = ((BIException) data).getMessage();
			this.msgEN = ((BIException) data).getMsgEN();
			this.statusCode=((BIException) data).getExceptionCode();
			//this.data=(T) new String("");
		}else{
			this.data=data;
		}
	}

	public RestResponse(int statusCode, String msg) {
		this(statusCode,msg,"",null);
	}
	

	
	public RestResponse(int statusCode, String msg, T data) {
		this(statusCode,msg,"",data);
		
	}
	

	public RestResponse(int statusCode, String msg,String msgEN, T data) {
		super();
		this.statusCode = statusCode;
		this.msg = msg;
		this.msgEN = msgEN;
		this.data = data;
		
	}
	
	public int getStatusCode() {
		return statusCode;
	}
	public void setStatusCode(int statusCode) {
		this.statusCode = statusCode;
	}
	public String getMsg() {
		return msg;
	}
	public void setMsg(String msg) {
		this.msg = msg;
	}

	public T getData() {
		return data;
	}

	public void setData(T data) {
		this.data = data;
	}

	public Boolean isSuccess() {
		if(this.statusCode==0)
			return true;
		else
			return false;
	}
	
	
	public String getMsgEN() {
		return msgEN;
	}

	public void setMsgEN(String msgEN) {
		this.msgEN = msgEN;
	}

	@Override
	public String toString() {
		return "RestResponse [statusCode=" + statusCode + ", msg=" + msg + ", data=" + data + "]";
	}
}
